use sea_orm::{Database, EntityTrait, ActiveModelTrait, Set};
use uuid::Uuid;
use chrono::Utc;
use rust_decimal::Decimal;

mod entities;
use entities::vehicle;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let database_url = "mysql://root:password@localhost:3306/tms";
    let db = Database::connect(database_url).await?;
    
    let id = Uuid::new_v4().to_string();
    let now = Utc::now().naive_utc();
    
    println!("Creating vehicle with ID: {}", id);
    
    let vehicle = vehicle::ActiveModel {
        id: Set(id.clone()),
        license_plate: Set("DEBUG001".to_string()),
        model: Set("Debug Vehicle".to_string()),
        max_weight: Set(Decimal::from(20)),
        max_volume: Set(Decimal::from(80)),
        vehicle_type: Set(0),
        status: Set(0),
        driver_id: Set(None),
        created_at: Set(now),
        updated_at: Set(now),
    };
    
    println!("Calling insert()...");
    let result = vehicle.insert(&db).await?;
    println!("Insert successful! Result: {:?}", result);
    
    Ok(())
}